using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;

namespace NetMsg.Task
{
    public enum TaskItemType
    {
        Gift,
        Equip,
        Food,
    }
    
    public struct TaskItem : IPackable, IUnPackable
    {
        public TaskItemType Type;
        public int Param;
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, (uint)Type);
            PackAuxiliary.Write(stream, (uint)Param);
        }
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Type = (TaskItemType)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Param = (int)var1;
        }
    }
    
    public class TaskInfo : IUnPackable
    {
        public int TaskId;
        public int CfgId;
        public List<TaskItem> HasItems;
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TaskId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
            UnPackAuxiliary.Read(stream, out uint var2);
            HasItems = new List<TaskItem>((int)var2);
            for(var i = 0; i < var2; ++i)
            {
                var var3 = new TaskItem();
                var3.UnPack(stream);
                HasItems.Add(var3);
            }
        }
    }
    
    public struct GetTasksQ : IServerCallbackable
    {
        public uint UnPackableId => 97;
        public uint PackableId => 125;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 125u);
        }
    }
    
    public class GetTasksP : IUnPackable
    {
        public List<TaskInfo> Tasks;
        public const uint Sid = 97;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Tasks = new List<TaskInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new TaskInfo();
                var1.UnPack(stream);
                Tasks.Add(var1);
            }
        }
    }
    
    // 新任务
    public struct NewTaskP : IUnPackable
    {
        public int TaskId;
        public int CfgId;
        public const uint Sid = 98;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TaskId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
        }
    }
    
    // 完成任务
    public struct CompleteTaskQ : IServerCallbackable
    {
        public int TaskId;
        public uint UnPackableId => 99;
        public uint PackableId => 126;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 126u);
            PackAuxiliary.Write(stream, (uint)TaskId);
        }
    }
    
    public struct CompleteTaskP : IUnPackable
    {
        public int TaskId;
        public int CfgId;
        public const uint Sid = 99;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            TaskId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
        }
    }
    
    public enum TaskEnum
    {
        GetTasksP,
        NewTaskP,
        CompleteTaskP,
    }
}
